<template>
	<!--选择险种代码-->
	<el-dialog title="选择险种代码" :visible.sync="dialogVisible" size="small" :close-on-click-modal="false" :close-on-press-escape="false" :before-close="off">
		  <el-form label-width="150px" >
		  <el-row :span="24">
		  	<el-form-item label="险种代码" label-width="150px" :span="24">
				<el-select v-model="arrayRiskcodes" multiple  placeholder="险种代码" filterable size="small" style="width:80%">
					<el-option v-for="item in riskOptions" :key="item.riskcode" :label="item.riskcode + '-' + item.riskcname" :value="item.riskcode"></el-option>
				</el-select>
			</el-form-item>
		  </el-row>
		</el-form>
		  <span slot="footer" class="dialog-footer">
			   <el-button @click="off">取 消</el-button>
			   <el-button type="danger" @click="clear">清 空</el-button>
			   <el-button type="success" @click="select">确 定</el-button>
		  </span>
	</el-dialog>
</template>

<script>

import RiskAPI from "../../../js/production/risk/riskAPI";

  export default {
	data() {
		return {
			dialogVisible: true,
			arrayRiskcodes: [],
			riskOptions: [],
		}
	},
	mounted() {
		RiskAPI.initRiskSelect(this);
		this.arrayRiskcodes = this.$parent.arrayRiskcodes;
	},
	methods: {
		select() {
			this.$parent.arrayRiskcodes = [];
			this.$parent.riskCodesLabel = '';
			this.$parent.arrayRiskcodes = this.arrayRiskcodes;
			for(let i = 0; i <this.arrayRiskcodes.length - 1; i++) {
				this.$parent.riskCodesLabel += this.arrayRiskcodes[i] + ",";
			}
			if(this.arrayRiskcodes.length > 0) {
				this.$parent.riskCodesLabel += this.arrayRiskcodes[this.arrayRiskcodes.length - 1];
			}
			this.off();
		},
		clear() {
			this.arrayRiskcodes = [];
			this.$parent.arrayRiskcodes = [];
			this.$parent.riskCodesLabel = '';
			this.off();
		},
		off() {
			this.$parent.showRiskCodeSelectDialog = false;
		}
	}
  }
</script>